package com.sll.hosptials.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sll.hosptials.controller.req.AddOrUpdateOrgInfoReq;
import com.sll.hosptials.controller.req.IdReq;
import com.sll.hosptials.controller.req.OrgInfoListReq;
import com.sll.hosptials.controller.req.OrgInfoPageReq;
import com.sll.hosptials.dto.OrgInfoDTO;
import com.sll.hosptials.controller.resp.OrgInfoPageResp;
import com.sll.hosptials.service.OrgInfoService;
import com.sll.hosptials.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "组织信息")
@RequestMapping("/orgInfo/")
@RestController
public class OrgInfoController {
    @Resource
    private OrgInfoService orgInfoService;


    @ApiOperation("新增")
    @PostMapping("/addOrUpdate")
    public Result<Boolean> addOrUpdate(@RequestBody AddOrUpdateOrgInfoReq req){
        return Result.success(orgInfoService.addOrgInfo(req));
    }

    @ApiOperation("组织信息分页")
    @PostMapping("/page")
    public Result<Page<OrgInfoPageResp>> page(@RequestBody OrgInfoPageReq req){
        return Result.success(orgInfoService.orgInfoPage(req));
    }

    @ApiOperation("获取所有组织信息")
    @PostMapping("/allOrgInfo")
    public Result<List<OrgInfoPageResp>> allOrgInfo(@RequestBody OrgInfoListReq req){
        return Result.success(orgInfoService.getOrgInfoList(req));
    }

    @ApiOperation("获取详情")
    @PostMapping("/detail")
    public Result<OrgInfoDTO> userDetail(@RequestBody IdReq req) {
        return Result.success(orgInfoService.orgInfoDetail(req.getId()));
    }

    @ApiOperation("删除")
    @PostMapping("/delete")
    public Result<Boolean> delete(@RequestBody IdReq req) {
        return Result.success(orgInfoService.delete(req));
    }

}
